﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GenericGA.extrandom;

namespace GenericGA.generationmaker.crossover
{
    /// <summary>
    /// Cross 2 chromosomes using a single crossover point.
    /// </summary>
    public class SinglePointCrossover : Crossover
    {

        /// <summary>
        /// The algorithm to create an arbitrary number of crossover points.
        /// </summary>
        private readonly NPointCrossover nPointCrossover;

        /// <summary>
        /// Constructor to create a SinglePointCrossover object.
        /// </summary>
        /// <param name="randGen">A random number generator.</param>
        public SinglePointCrossover(ExtRandom randGen)
        {
            nPointCrossover = new NPointCrossover(randGen, 1);
        }

        /// <summary>
        /// Cross over the genetic material of two chromosomes by overwriting them.
        /// </summary>
        /// <param name="bits1">One of the 2 chromosomes to cross over. Will be modified.</param>
        /// <param name="bits2">One of the 2 chromosomes to cross over. Will be modified.</param>
        public override void Cross(List<ulong> offspring1, List<ulong> offspring2)
        {
            nPointCrossover.Cross(offspring1, offspring2);
        }

    }
}
